<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/taglibs.jsp"%>

<table id="assignrolegrid" style="width:100%;"></table>

<script type="text/javascript">
$(function(){
    var $assignrolegrid = $('#assignrolegrid');
    $assignrolegrid.datagrid({
        data: eval('${roles}'),
        columns: [[
            {field: 'id', title: '角色ID', sortable: true, width: 100},
            {field: 'name', title: '角色名', sortable: true, width: 100}
        ]],
        frozenColumns: [[
            {field: 'ck', checkbox: true}
        ]],
        idField: 'id',
        border: false,
        rownumbers: true,
        fitColumns: true,
        collapsible: true,
        singleSelect: false,
        selectOnCheck: true,
        checkOnSelect: true,
        remoteSort: false,
        onLoadSuccess: function(data) {
            var assignIds = eval('${assignedIds}');
            $.each(data.rows, function(i, role) {
                if ($.inArray(role.id, assignIds) >= 0) {
                    var index = $assignrolegrid.datagrid('getRowIndex', role);
                    $assignrolegrid.datagrid('checkRow', index);
                }
            });
        }
    });
})
</script>
